<?php

require_once '../config.php';
require_once '../db/put/post.php';
require_once '../db/get/post.php';
require_once '../util/redirect.php';
require_once '../util/consts.php';
require_once '../util/xhtml.php';

function handle($post,$data) {

  $stream = intval($post['stream']);
  $title = (string)$post['title'];
  $datum = (string)$post['datum'];
  $tid = intval((string)$post['tid']);
  $psize = (isset($data['psize'])) ? intval($data['psize']) : DEFAULT_POST_PAGE_SIZE;

  $page = ceil(postCount($tid)/$psize);

  $smurfkey = '';

  if( newPost( $stream, $title, $datum, $smurfKey ) == MSG_UNAUTHORIZED )
    echo 'BREAKAGE';
  
  sendto( str_replace('&amp;', '&', linkAt(VIEW_POST, array('tid'=>$tid, 'psize'=>$psize, 'page'=>$page) ) ) );
}


?>
